package partida.estados
{
	// ========================================================================
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import gs.TweenMax;
	import gs.easing.Linear;
	
	import kapi.API;
	
	import partida.Estado;
	import partida.Partida;
	// ========================================================================

	public class Creditos implements Estado
	{
		// ====================================================================
		private var _partida:Partida
		private var tween:TweenMax
		private var creditos:MovieClip
		private var cortina:Sprite
		// ====================================================================

		// ====================================================================
		// PROEPRTIES
		// ====================================================================

		// --------------------------------------------------------------------
		public function get nombre():String { return 'CREDITOS' }

		// ====================================================================
		// FUNCIONES
		// ====================================================================

		// --------------------------------------------------------------------
		public function entrar(_partida:Partida):void
		{
			this._partida = _partida

			creditos = new API.recursos['mcCreditos']()
			API.root.addChild(creditos)

			/*			
			volver = new Boton(creditos.volver)
			volver.alPresionar.escuchar(desvanecer)
			*/

			var o:Object = new Object()
			o.frame = 300
			o.ease = gs.easing.Linear.easeNone
			o.onComplete = desvanecer
			o.startAt = new Object()
			o.startAt.frame = 0
			tween = TweenMax.to(creditos, 10, o)
		}
		// --------------------------------------------------------------------
		private function desvanecer():void
		{
			if (tween)
				tween.pause()

			cortina = new Sprite()
			cortina.graphics.beginFill(0x000000, 1)
			cortina.graphics.drawRect(0, 0, API.stage.stageWidth, API.stage.stageHeight)
			creditos.addChild(cortina)

			var o:Object = new Object()
			o.alpha = 1
			o.ease = gs.easing.Linear.easeNone
			o.onComplete = mostrarMenu
			o.startAt = new Object()
			o.startAt.alpha = 0
			tween = TweenMax.to(cortina, 1, o)
		}
		// --------------------------------------------------------------------
		private function mostrarMenu():void
		{
			creditos.removeChild(cortina)
			_partida.mostrarMenu()
		}
		// --------------------------------------------------------------------
		public function salir():void
		{
			API.root.removeChild(creditos)
		}
	}
}